package com.nfc.lock.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 锁具列表VO
 */
@Data
@Schema(description = "锁具列表")
public class LockListVO {

    @Schema(description = "锁具ID")
    private Long lockId;

    @Schema(description = "NFC ID")
    private String lockNfcId;

    @Schema(description = "配电室ID")
    private Long roomId;

    @Schema(description = "配电室名称")
    private String roomName;

    @Schema(description = "区域名称")
    private String regionName;

    @Schema(description = "锁具状态: 0-关闭 1-开启")
    private Integer lockStatus;

    @Schema(description = "锁具状态名称")
    private String lockStatusName;

    @Schema(description = "是否损坏: 0-否 1-是")
    private Integer isDamaged;

    @Schema(description = "最后操作时间")
    private LocalDateTime lastOperateTime;

    @Schema(description = "最后操作人")
    private String lastOperateUserName;

    @Schema(description = "开锁时长（分钟）")
    private Integer unlockDuration;

    /**
     * 获取锁具状态名称
     */
    public String getLockStatusName() {
        if (isDamaged != null && isDamaged == 1) {
            return "已损坏";
        }
        if (lockStatus == null) {
            return "未知";
        }
        return lockStatus == 0 ? "关闭" : "开启";
    }
}
